function format(template) {
  return replace(template, [].slice.call(arguments, 1))
}

function replace(template, data) {
  return template.replace(/{([^{]*?)}/g, function (match, key) {
    return data[key] == null ? match : data[key]
    });
}

function padLeft(str, len, char) {
  return (char.repeat(len) + str).substr(-len);
}

function padRight(str, len, char) {
  return (str + char.repeat(len)).substr(0, len);
}

var StringHelper = {
  format: format,
  replace: replace,
  padLeft: padLeft,
  padRight: padRight
}

module.exports = StringHelper;
